ts-markdown-builder 0.2.2 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -4
- package/dist/commonjs/block.js +3 -2
- package/dist/commonjs/block.js.map +1 -1
- package/dist/commonjs/html.js +4 -1
- package/dist/commonjs/html.js.map +1 -1
- package/dist/commonjs/index.js +2 -8
- package/dist/commonjs/index.js.map +1 -1
- package/dist/commonjs/inline.js.map +1 -1
- package/dist/commonjs/utils.js +8 -0
- package/dist/commonjs/utils.js.map +1 -1
- package/dist/esm/block.mjs +4 -3
- package/dist/esm/block.mjs.map +1 -1
- package/dist/esm/html.mjs +4 -1
- package/dist/esm/html.mjs.map +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/inline.mjs.map +1 -1
- package/dist/esm/utils.mjs +7 -0
- package/dist/esm/utils.mjs.map +1 -1
- package/dist/types/block.d.ts +6 -2
- package/dist/types/html.d.ts +5 -5
- package/dist/types/index.d.ts +1 -1
- package/dist/types/inline.d.ts +1 -1
- package/dist/types/utils.d.ts +7 -0
- package/package.json +45 -11
- package/dist/commonjs/join.js +0 -15
- package/dist/commonjs/join.js.map +0 -1
- package/dist/esm/join.mjs +0 -11
- package/dist/esm/join.mjs.map +0 -1
- package/dist/types/join.d.ts +0 -14
package/README.md
CHANGED
|
@@ -11,9 +11,10 @@ Elegant markdown builder with minimal bundle size.
|
|
|
11
11
|
## Goal
|
|
12
12
|
|
|
13
13
|
TypeScript markdown generation library:
|
|
14
|
+
|
|
14
15
|
- easy to read and write API
|
|
15
16
|
- build CommonMark & GFM compliant markdown
|
|
16
|
-
- minimal bundle size + tree-shakable
|
|
17
|
+
- minimal bundle size + tree-shakable
|
|
17
18
|
|
|
18
19
|
## Installation
|
|
19
20
|
|
|
@@ -26,7 +27,7 @@ npm install ts-markdown-builder
|
|
|
26
27
|
```js
|
|
27
28
|
import * as md from 'ts-markdown-builder';
|
|
28
29
|
|
|
29
|
-
const output =
|
|
30
|
+
const output = [
|
|
30
31
|
md.heading('Welcome to TS Markdown Builder'),
|
|
31
32
|
"It's an easy to use modern markdown generator.",
|
|
32
33
|
'It supports:',
|
|
@@ -37,7 +38,7 @@ const output = md.joinBlocks([
|
|
|
37
38
|
'blockquotes',
|
|
38
39
|
'and more!',
|
|
39
40
|
]),
|
|
40
|
-
]);
|
|
41
|
+
].join('\n\n');
|
|
41
42
|
```
|
|
42
43
|
|
|
43
44
|
```markdown
|
|
@@ -47,7 +48,7 @@ It's an easy to use modern markdown generator.
|
|
|
47
48
|
|
|
48
49
|
It supports:
|
|
49
50
|
|
|
50
|
-
- **bold** and
|
|
51
|
+
- **bold** and _italic_
|
|
51
52
|
- \`code\` spans and code blocks
|
|
52
53
|
- unordered and ordered lists
|
|
53
54
|
- blockquotes
|
package/dist/commonjs/block.js
CHANGED
|
@@ -8,11 +8,12 @@ exports.list = list;
|
|
|
8
8
|
exports.orderedList = orderedList;
|
|
9
9
|
var _utils = require("./utils.js");
|
|
10
10
|
const horizontalRule = exports.horizontalRule = '---';
|
|
11
|
-
function heading(text,
|
|
11
|
+
function heading(text, options) {
|
|
12
|
+
const level = options?.level ?? 1;
|
|
12
13
|
return `${'#'.repeat(level)} ${text}`;
|
|
13
14
|
}
|
|
14
15
|
function blockquote(content) {
|
|
15
|
-
return (0, _utils.prefixLines)(content, '> ');
|
|
16
|
+
return (0, _utils.prefixLines)((0, _utils.joinBlocks)(content), '> ');
|
|
16
17
|
}
|
|
17
18
|
function codeBlock(content) {
|
|
18
19
|
return `\`\`\`\n${content}\n\`\`\``;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"block.js","names":["horizontalRule","exports","heading","text","level","repeat","blockquote","content","prefixLines","codeBlock","list","items","map","item","join","orderedList","index"],"sources":["../../src/block.ts"],"sourcesContent":["import { prefixLines } from './utils';\n\n/**\n * Create a horizontal rule block.\n *\n * Markdown: `---`\n */\nexport const horizontalRule = '---';\n\n/**\n * Create a heading block.\n * Markdown: `# Heading`\n *\n * @param text - The text of the heading.\n * @param level - The level of the heading (defaults to 1).\n */\nexport function heading(text: string,
|
|
1
|
+
{"version":3,"file":"block.js","names":["horizontalRule","exports","heading","text","options","level","repeat","blockquote","content","prefixLines","joinBlocks","codeBlock","list","items","map","item","join","orderedList","index"],"sources":["../../src/block.ts"],"sourcesContent":["import { joinBlocks, prefixLines } from './utils';\n\n/**\n * Create a horizontal rule block.\n *\n * Markdown: `---`\n */\nexport const horizontalRule = '---';\n\ntype HeadingOptions = {\n level: number;\n};\n\n/**\n * Create a heading block.\n * Markdown: `# Heading`\n *\n * @param text - The text of the heading.\n * @param level - The level of the heading (defaults to 1).\n */\nexport function heading(text: string, options?: HeadingOptions): string {\n const level = options?.level ?? 1;\n return `${'#'.repeat(level)} ${text}`;\n}\n\n/**\n * Create a blockquote block.\n *\n * Markdown:\n * ```\n * > Content\n * > Content\n * ```\n *\n * @param text - The content of the blockquote.\n */\nexport function blockquote(content: string | readonly string[]): string {\n return prefixLines(joinBlocks(content), '> ');\n}\n\n/**\n * Create a code block.\n *\n * Markdown:\n * ````\n * ```\n * Content\n * ```\n * ````\n *\n * @param content - The content of the code block.\n */\nexport function codeBlock(content: string): string {\n return `\\`\\`\\`\\n${content}\\n\\`\\`\\``;\n}\n\n/**\n * Create an unordered list block.\n *\n * Markdown:\n * ```\n * - Item\n * - Item\n * ```\n *\n * @param items - The items of the list.\n */\nexport function list(items: readonly string[]): string {\n return items.map((item) => `- ${item}`).join('\\n');\n}\n\n/**\n * Create an ordered list block.\n *\n * Markdown:\n * ```\n * 1. Item\n * 2. Item\n * ```\n *\n * @param items - The items of the list.\n */\nexport function orderedList(items: readonly string[]): string {\n return items.map((item, index) => `${index + 1}. ${item}`).join('\\n');\n}\n"],"mappings":";;;;;;;;;AAOO,MAAMA,cAAc,GAAAC,OAAA,CAAAD,cAAA,GAAG,KAAK;AAa5B,SAASE,OAAOA,CAACC,IAAY,EAAEC,OAAwB,EAAU;EACtE,MAAMC,KAAK,GAAGD,OAAO,EAAEC,KAAK,IAAI,CAAC;EACjC,OAAO,GAAG,GAAG,CAACC,MAAM,CAACD,KAAK,CAAC,IAAIF,IAAI,EAAE;AACvC;AAaO,SAASI,UAAUA,CAACC,OAAmC,EAAU;EACtE,OAAO,IAAAC,kBAAW,EAAC,IAAAC,iBAAU,EAACF,OAAO,CAAC,EAAE,IAAI,CAAC;AAC/C;AAcO,SAASG,SAASA,CAACH,OAAe,EAAU;EACjD,OAAO,WAAWA,OAAO,UAAU;AACrC;AAaO,SAASI,IAAIA,CAACC,KAAwB,EAAU;EACrD,OAAOA,KAAK,CAACC,GAAG,CAAEC,IAAI,IAAK,KAAKA,IAAI,EAAE,CAAC,CAACC,IAAI,CAAC,IAAI,CAAC;AACpD;AAaO,SAASC,WAAWA,CAACJ,KAAwB,EAAU;EAC5D,OAAOA,KAAK,CAACC,GAAG,CAAC,CAACC,IAAI,EAAEG,KAAK,KAAK,GAAGA,KAAK,GAAG,CAAC,KAAKH,IAAI,EAAE,CAAC,CAACC,IAAI,CAAC,IAAI,CAAC;AACvE","ignoreList":[]}
|
package/dist/commonjs/html.js
CHANGED
|
@@ -7,7 +7,10 @@ function disclosure(title, content, options) {
|
|
|
7
7
|
const headerHack = title.startsWith('#') ? '\n\n' : '';
|
|
8
8
|
return `<details${options?.open ? ' open' : ''}>
|
|
9
9
|
<summary>${headerHack}${title}${headerHack}</summary>
|
|
10
|
-
|
|
10
|
+
${escapeMarkdownInHtml(content)}
|
|
11
11
|
</details>`;
|
|
12
12
|
}
|
|
13
|
+
function escapeMarkdownInHtml(markdown) {
|
|
14
|
+
return `\n${markdown}\n`;
|
|
15
|
+
}
|
|
13
16
|
//# sourceMappingURL=html.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html.js","names":["lineBreak","exports","disclosure","title","content","options","headerHack","startsWith","open"],"sources":["../../src/html.ts"],"sourcesContent":["/**\n * Create a line break.\n *\n * Markdown
|
|
1
|
+
{"version":3,"file":"html.js","names":["lineBreak","exports","disclosure","title","content","options","headerHack","startsWith","open","escapeMarkdownInHtml","markdown"],"sources":["../../src/html.ts"],"sourcesContent":["/**\n * Create a line break.\n *\n * Markdown (as HTML): `<br/>`\n */\nexport const lineBreak = '<br/>';\n\n/**\n * Options for the `disclosure` block.\n */\nexport type DisclosureOptions = {\n /**\n * Whether the disclosure block should be open by default (defaults to false).\n */\n open?: boolean;\n};\n\n/**\n * Create a disclosure block.\n *\n * Markdown (as HTML):\n * ```\n * <details>\n * <summary>Title</summary>\n * Content\n * </details>\n * ```\n *\n * @param title - The title of the disclosure (text only or markdown heading: `# heading`).\n * @param content - The content of the disclosure (can include markdown).\n * @param options - The options for the disclosure.\n */\nexport function disclosure(title: string, content: string, options?: DisclosureOptions): string {\n // Add extra with lines to render header properly. New line should not be added for regular text\n // as it messes up the formatting.\n const headerHack = title.startsWith('#') ? '\\n\\n' : '';\n\n return `<details${options?.open ? ' open' : ''}>\n<summary>${headerHack}${title}${headerHack}</summary>\n${escapeMarkdownInHtml(content)}\n</details>`;\n}\n\n// Blank lines are required for rendering a markdown section inside html tag.\n// See https://gist.github.com/scmx/eca72d44afee0113ceb0349dd54a84a2\nfunction escapeMarkdownInHtml(markdown: string): string {\n return `\\n${markdown}\\n`;\n}\n"],"mappings":";;;;AAKO,MAAMA,SAAS,GAAAC,OAAA,CAAAD,SAAA,GAAG,OAAO;AA2BzB,SAASE,UAAUA,CAACC,KAAa,EAAEC,OAAe,EAAEC,OAA2B,EAAU;EAG9F,MAAMC,UAAU,GAAGH,KAAK,CAACI,UAAU,CAAC,GAAG,CAAC,GAAG,MAAM,GAAG,EAAE;EAEtD,OAAO,WAAWF,OAAO,EAAEG,IAAI,GAAG,OAAO,GAAG,EAAE;AAChD,WAAWF,UAAU,GAAGH,KAAK,GAAGG,UAAU;AAC1C,EAAEG,oBAAoB,CAACL,OAAO,CAAC;AAC/B,WAAW;AACX;AAIA,SAASK,oBAAoBA,CAACC,QAAgB,EAAU;EACtD,OAAO,KAAKA,QAAQ,IAAI;AAC1B","ignoreList":[]}
|
package/dist/commonjs/index.js
CHANGED
|
@@ -57,13 +57,7 @@ Object.defineProperty(exports, "italic", {
|
|
|
57
57
|
Object.defineProperty(exports, "joinBlocks", {
|
|
58
58
|
enumerable: true,
|
|
59
59
|
get: function () {
|
|
60
|
-
return
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
Object.defineProperty(exports, "joinLines", {
|
|
64
|
-
enumerable: true,
|
|
65
|
-
get: function () {
|
|
66
|
-
return _join.joinLines;
|
|
60
|
+
return _utils.joinBlocks;
|
|
67
61
|
}
|
|
68
62
|
});
|
|
69
63
|
Object.defineProperty(exports, "lineBreak", {
|
|
@@ -96,9 +90,9 @@ Object.defineProperty(exports, "table", {
|
|
|
96
90
|
return _table.table;
|
|
97
91
|
}
|
|
98
92
|
});
|
|
99
|
-
var _join = require("./join.js");
|
|
100
93
|
var _block = require("./block.js");
|
|
101
94
|
var _inline = require("./inline.js");
|
|
102
95
|
var _table = require("./table.js");
|
|
103
96
|
var _html = require("./html.js");
|
|
97
|
+
var _utils = require("./utils.js");
|
|
104
98
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/index.ts"],"sourcesContent":["export {
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/index.ts"],"sourcesContent":["export { horizontalRule, heading, blockquote, orderedList, list, codeBlock } from './block';\nexport { code, italic, bold, link, image } from './inline';\nexport { table } from './table';\nexport { lineBreak, disclosure } from './html';\nexport { joinBlocks } from './utils';\n\nexport type { TableOptions } from './table';\nexport type { DisclosureOptions } from './html';\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inline.js","names":["italic","text","bold","code","link","url","image"],"sources":["../../src/inline.ts"],"sourcesContent":["/**\n * Create an italic text.\n *\n * Markdown: `*text*`\n *\n * @param text - The text to be italicized.\n */\nexport function italic(text: string): string {\n return `*${text}*`;\n}\n\n/**\n * Create a bold text.\n *\n * Markdown: `**text**`\n *\n * @param text - The text to be bolded.\n */\nexport function bold(text: string): string {\n return `**${text}**`;\n}\n\n/**\n * Create a code text.\n *\n * Markdown:
|
|
1
|
+
{"version":3,"file":"inline.js","names":["italic","text","bold","code","link","url","image"],"sources":["../../src/inline.ts"],"sourcesContent":["/**\n * Create an italic text.\n *\n * Markdown: `*text*`\n *\n * @param text - The text to be italicized.\n */\nexport function italic(text: string): string {\n return `*${text}*`;\n}\n\n/**\n * Create a bold text.\n *\n * Markdown: `**text**`\n *\n * @param text - The text to be bolded.\n */\nexport function bold(text: string): string {\n return `**${text}**`;\n}\n\n/**\n * Create a code text.\n *\n * Markdown: `code`\n *\n * @param text - The text to be marked as code.\n */\nexport function code(text: string): string {\n return `\\`${text}\\``;\n}\n\n/**\n * Create a link or autolink span.\n *\n * Markdown:\n * - `[text](url)` link when `text` is provided\n * - `<url>` autolink when `text` is not provided\n *\n * @param url - The URL to be linked.\n * @param text - The title for the link (optional).\n */\nexport function link(url: string, text?: string): string {\n return text ? `[${text}](${url})` : `<${url}>`;\n}\n\n/**\n * Create an image text.\n *\n * Markdown: ``\n *\n * @param url - The URL of the image.\n * @param text - The description for the image (optional).\n */\nexport function image(url: string, text?: string): string {\n return ``;\n}\n"],"mappings":";;;;;;;AAOO,SAASA,MAAMA,CAACC,IAAY,EAAU;EAC3C,OAAO,IAAIA,IAAI,GAAG;AACpB;AASO,SAASC,IAAIA,CAACD,IAAY,EAAU;EACzC,OAAO,KAAKA,IAAI,IAAI;AACtB;AASO,SAASE,IAAIA,CAACF,IAAY,EAAU;EACzC,OAAO,KAAKA,IAAI,IAAI;AACtB;AAYO,SAASG,IAAIA,CAACC,GAAW,EAAEJ,IAAa,EAAU;EACvD,OAAOA,IAAI,GAAG,IAAIA,IAAI,KAAKI,GAAG,GAAG,GAAG,IAAIA,GAAG,GAAG;AAChD;AAUO,SAASC,KAAKA,CAACD,GAAW,EAAEJ,IAAa,EAAU;EACxD,OAAO,KAAKA,IAAI,IAAI,EAAE,KAAKI,GAAG,GAAG;AACnC","ignoreList":[]}
|
package/dist/commonjs/utils.js
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
exports.joinBlocks = joinBlocks;
|
|
3
4
|
exports.prefixLines = prefixLines;
|
|
5
|
+
function joinBlocks(blocks) {
|
|
6
|
+
blocks = typeof blocks === 'string' ? [blocks] : blocks;
|
|
7
|
+
return blocks.map(trimBlock).filter(Boolean).join('\n\n');
|
|
8
|
+
}
|
|
9
|
+
function trimBlock(block) {
|
|
10
|
+
return block.replace(/^\n+|\n+$/g, '');
|
|
11
|
+
}
|
|
4
12
|
function prefixLines(text, prefix) {
|
|
5
13
|
const lines = text.split('\n');
|
|
6
14
|
return lines.map(line => `${prefix}${line}`).join('\n');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":["prefixLines","text","prefix","lines","split","
|
|
1
|
+
{"version":3,"file":"utils.js","names":["joinBlocks","blocks","map","trimBlock","filter","Boolean","join","block","replace","prefixLines","text","prefix","lines","split","line"],"sources":["../../src/utils.ts"],"sourcesContent":["/**\n * Join blocks of text into a single markdown document (string).\n *\n * @param blocks - The blocks of text to join.\n * @returns Markdown document string.\n */\nexport function joinBlocks(blocks: string | readonly string[]): string {\n blocks = typeof blocks === 'string' ? [blocks] : blocks;\n\n return blocks.map(trimBlock).filter(Boolean).join('\\n\\n');\n}\n\nfunction trimBlock(block: string): string {\n return block.replace(/^\\n+|\\n+$/g, '');\n}\n\nexport function prefixLines(text: string, prefix: string): string {\n const lines = text.split('\\n');\n return lines.map((line) => `${prefix}${line}`).join('\\n');\n}\n"],"mappings":";;;;AAMO,SAASA,UAAUA,CAACC,MAAkC,EAAU;EACrEA,MAAM,GAAG,OAAOA,MAAM,KAAK,QAAQ,GAAG,CAACA,MAAM,CAAC,GAAGA,MAAM;EAEvD,OAAOA,MAAM,CAACC,GAAG,CAACC,SAAS,CAAC,CAACC,MAAM,CAACC,OAAO,CAAC,CAACC,IAAI,CAAC,MAAM,CAAC;AAC3D;AAEA,SAASH,SAASA,CAACI,KAAa,EAAU;EACxC,OAAOA,KAAK,CAACC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC;AACxC;AAEO,SAASC,WAAWA,CAACC,IAAY,EAAEC,MAAc,EAAU;EAChE,MAAMC,KAAK,GAAGF,IAAI,CAACG,KAAK,CAAC,IAAI,CAAC;EAC9B,OAAOD,KAAK,CAACV,GAAG,CAAEY,IAAI,IAAK,GAAGH,MAAM,GAAGG,IAAI,EAAE,CAAC,CAACR,IAAI,CAAC,IAAI,CAAC;AAC3D","ignoreList":[]}
|
package/dist/esm/block.mjs
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { prefixLines } from "./utils.mjs";
|
|
1
|
+
import { joinBlocks, prefixLines } from "./utils.mjs";
|
|
2
2
|
export const horizontalRule = '---';
|
|
3
|
-
export function heading(text,
|
|
3
|
+
export function heading(text, options) {
|
|
4
|
+
const level = options?.level ?? 1;
|
|
4
5
|
return `${'#'.repeat(level)} ${text}`;
|
|
5
6
|
}
|
|
6
7
|
export function blockquote(content) {
|
|
7
|
-
return prefixLines(content, '> ');
|
|
8
|
+
return prefixLines(joinBlocks(content), '> ');
|
|
8
9
|
}
|
|
9
10
|
export function codeBlock(content) {
|
|
10
11
|
return `\`\`\`\n${content}\n\`\`\``;
|
package/dist/esm/block.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"block.mjs","names":["prefixLines","horizontalRule","heading","text","level","repeat","blockquote","content","codeBlock","list","items","map","item","join","orderedList","index"],"sources":["../../src/block.ts"],"sourcesContent":["import { prefixLines } from './utils';\n\n/**\n * Create a horizontal rule block.\n *\n * Markdown: `---`\n */\nexport const horizontalRule = '---';\n\n/**\n * Create a heading block.\n * Markdown: `# Heading`\n *\n * @param text - The text of the heading.\n * @param level - The level of the heading (defaults to 1).\n */\nexport function heading(text: string,
|
|
1
|
+
{"version":3,"file":"block.mjs","names":["joinBlocks","prefixLines","horizontalRule","heading","text","options","level","repeat","blockquote","content","codeBlock","list","items","map","item","join","orderedList","index"],"sources":["../../src/block.ts"],"sourcesContent":["import { joinBlocks, prefixLines } from './utils';\n\n/**\n * Create a horizontal rule block.\n *\n * Markdown: `---`\n */\nexport const horizontalRule = '---';\n\ntype HeadingOptions = {\n level: number;\n};\n\n/**\n * Create a heading block.\n * Markdown: `# Heading`\n *\n * @param text - The text of the heading.\n * @param level - The level of the heading (defaults to 1).\n */\nexport function heading(text: string, options?: HeadingOptions): string {\n const level = options?.level ?? 1;\n return `${'#'.repeat(level)} ${text}`;\n}\n\n/**\n * Create a blockquote block.\n *\n * Markdown:\n * ```\n * > Content\n * > Content\n * ```\n *\n * @param text - The content of the blockquote.\n */\nexport function blockquote(content: string | readonly string[]): string {\n return prefixLines(joinBlocks(content), '> ');\n}\n\n/**\n * Create a code block.\n *\n * Markdown:\n * ````\n * ```\n * Content\n * ```\n * ````\n *\n * @param content - The content of the code block.\n */\nexport function codeBlock(content: string): string {\n return `\\`\\`\\`\\n${content}\\n\\`\\`\\``;\n}\n\n/**\n * Create an unordered list block.\n *\n * Markdown:\n * ```\n * - Item\n * - Item\n * ```\n *\n * @param items - The items of the list.\n */\nexport function list(items: readonly string[]): string {\n return items.map((item) => `- ${item}`).join('\\n');\n}\n\n/**\n * Create an ordered list block.\n *\n * Markdown:\n * ```\n * 1. Item\n * 2. Item\n * ```\n *\n * @param items - The items of the list.\n */\nexport function orderedList(items: readonly string[]): string {\n return items.map((item, index) => `${index + 1}. ${item}`).join('\\n');\n}\n"],"mappings":"SAASA,UAAU,EAAEC,WAAW;AAOhC,OAAO,MAAMC,cAAc,GAAG,KAAK;AAanC,OAAO,SAASC,OAAOA,CAACC,IAAY,EAAEC,OAAwB,EAAU;EACtE,MAAMC,KAAK,GAAGD,OAAO,EAAEC,KAAK,IAAI,CAAC;EACjC,OAAO,GAAG,GAAG,CAACC,MAAM,CAACD,KAAK,CAAC,IAAIF,IAAI,EAAE;AACvC;AAaA,OAAO,SAASI,UAAUA,CAACC,OAAmC,EAAU;EACtE,OAAOR,WAAW,CAACD,UAAU,CAACS,OAAO,CAAC,EAAE,IAAI,CAAC;AAC/C;AAcA,OAAO,SAASC,SAASA,CAACD,OAAe,EAAU;EACjD,OAAO,WAAWA,OAAO,UAAU;AACrC;AAaA,OAAO,SAASE,IAAIA,CAACC,KAAwB,EAAU;EACrD,OAAOA,KAAK,CAACC,GAAG,CAAEC,IAAI,IAAK,KAAKA,IAAI,EAAE,CAAC,CAACC,IAAI,CAAC,IAAI,CAAC;AACpD;AAaA,OAAO,SAASC,WAAWA,CAACJ,KAAwB,EAAU;EAC5D,OAAOA,KAAK,CAACC,GAAG,CAAC,CAACC,IAAI,EAAEG,KAAK,KAAK,GAAGA,KAAK,GAAG,CAAC,KAAKH,IAAI,EAAE,CAAC,CAACC,IAAI,CAAC,IAAI,CAAC;AACvE","ignoreList":[]}
|
package/dist/esm/html.mjs
CHANGED
|
@@ -3,7 +3,10 @@ export function disclosure(title, content, options) {
|
|
|
3
3
|
const headerHack = title.startsWith('#') ? '\n\n' : '';
|
|
4
4
|
return `<details${options?.open ? ' open' : ''}>
|
|
5
5
|
<summary>${headerHack}${title}${headerHack}</summary>
|
|
6
|
-
|
|
6
|
+
${escapeMarkdownInHtml(content)}
|
|
7
7
|
</details>`;
|
|
8
8
|
}
|
|
9
|
+
function escapeMarkdownInHtml(markdown) {
|
|
10
|
+
return `\n${markdown}\n`;
|
|
11
|
+
}
|
|
9
12
|
//# sourceMappingURL=html.mjs.map
|
package/dist/esm/html.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html.mjs","names":["lineBreak","disclosure","title","content","options","headerHack","startsWith","open"],"sources":["../../src/html.ts"],"sourcesContent":["/**\n * Create a line break.\n *\n * Markdown
|
|
1
|
+
{"version":3,"file":"html.mjs","names":["lineBreak","disclosure","title","content","options","headerHack","startsWith","open","escapeMarkdownInHtml","markdown"],"sources":["../../src/html.ts"],"sourcesContent":["/**\n * Create a line break.\n *\n * Markdown (as HTML): `<br/>`\n */\nexport const lineBreak = '<br/>';\n\n/**\n * Options for the `disclosure` block.\n */\nexport type DisclosureOptions = {\n /**\n * Whether the disclosure block should be open by default (defaults to false).\n */\n open?: boolean;\n};\n\n/**\n * Create a disclosure block.\n *\n * Markdown (as HTML):\n * ```\n * <details>\n * <summary>Title</summary>\n * Content\n * </details>\n * ```\n *\n * @param title - The title of the disclosure (text only or markdown heading: `# heading`).\n * @param content - The content of the disclosure (can include markdown).\n * @param options - The options for the disclosure.\n */\nexport function disclosure(title: string, content: string, options?: DisclosureOptions): string {\n // Add extra with lines to render header properly. New line should not be added for regular text\n // as it messes up the formatting.\n const headerHack = title.startsWith('#') ? '\\n\\n' : '';\n\n return `<details${options?.open ? ' open' : ''}>\n<summary>${headerHack}${title}${headerHack}</summary>\n${escapeMarkdownInHtml(content)}\n</details>`;\n}\n\n// Blank lines are required for rendering a markdown section inside html tag.\n// See https://gist.github.com/scmx/eca72d44afee0113ceb0349dd54a84a2\nfunction escapeMarkdownInHtml(markdown: string): string {\n return `\\n${markdown}\\n`;\n}\n"],"mappings":"AAKA,OAAO,MAAMA,SAAS,GAAG,OAAO;AA2BhC,OAAO,SAASC,UAAUA,CAACC,KAAa,EAAEC,OAAe,EAAEC,OAA2B,EAAU;EAG9F,MAAMC,UAAU,GAAGH,KAAK,CAACI,UAAU,CAAC,GAAG,CAAC,GAAG,MAAM,GAAG,EAAE;EAEtD,OAAO,WAAWF,OAAO,EAAEG,IAAI,GAAG,OAAO,GAAG,EAAE;AAChD,WAAWF,UAAU,GAAGH,KAAK,GAAGG,UAAU;AAC1C,EAAEG,oBAAoB,CAACL,OAAO,CAAC;AAC/B,WAAW;AACX;AAIA,SAASK,oBAAoBA,CAACC,QAAgB,EAAU;EACtD,OAAO,KAAKA,QAAQ,IAAI;AAC1B","ignoreList":[]}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { joinBlocks, joinLines } from "./join.mjs";
|
|
2
1
|
export { horizontalRule, heading, blockquote, orderedList, list, codeBlock } from "./block.mjs";
|
|
3
2
|
export { code, italic, bold, link, image } from "./inline.mjs";
|
|
4
3
|
export { table } from "./table.mjs";
|
|
5
4
|
export { lineBreak, disclosure } from "./html.mjs";
|
|
5
|
+
export { joinBlocks } from "./utils.mjs";
|
|
6
6
|
//# sourceMappingURL=index.mjs.map
|
package/dist/esm/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["horizontalRule","heading","blockquote","orderedList","list","codeBlock","code","italic","bold","link","image","table","lineBreak","disclosure","joinBlocks"],"sources":["../../src/index.ts"],"sourcesContent":["export { horizontalRule, heading, blockquote, orderedList, list, codeBlock } from './block';\nexport { code, italic, bold, link, image } from './inline';\nexport { table } from './table';\nexport { lineBreak, disclosure } from './html';\nexport { joinBlocks } from './utils';\n\nexport type { TableOptions } from './table';\nexport type { DisclosureOptions } from './html';\n"],"mappings":"SAASA,cAAc,EAAEC,OAAO,EAAEC,UAAU,EAAEC,WAAW,EAAEC,IAAI,EAAEC,SAAS;AAAA,SACjEC,IAAI,EAAEC,MAAM,EAAEC,IAAI,EAAEC,IAAI,EAAEC,KAAK;AAAA,SAC/BC,KAAK;AAAA,SACLC,SAAS,EAAEC,UAAU;AAAA,SACrBC,UAAU","ignoreList":[]}
|
package/dist/esm/inline.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inline.mjs","names":["italic","text","bold","code","link","url","image"],"sources":["../../src/inline.ts"],"sourcesContent":["/**\n * Create an italic text.\n *\n * Markdown: `*text*`\n *\n * @param text - The text to be italicized.\n */\nexport function italic(text: string): string {\n return `*${text}*`;\n}\n\n/**\n * Create a bold text.\n *\n * Markdown: `**text**`\n *\n * @param text - The text to be bolded.\n */\nexport function bold(text: string): string {\n return `**${text}**`;\n}\n\n/**\n * Create a code text.\n *\n * Markdown:
|
|
1
|
+
{"version":3,"file":"inline.mjs","names":["italic","text","bold","code","link","url","image"],"sources":["../../src/inline.ts"],"sourcesContent":["/**\n * Create an italic text.\n *\n * Markdown: `*text*`\n *\n * @param text - The text to be italicized.\n */\nexport function italic(text: string): string {\n return `*${text}*`;\n}\n\n/**\n * Create a bold text.\n *\n * Markdown: `**text**`\n *\n * @param text - The text to be bolded.\n */\nexport function bold(text: string): string {\n return `**${text}**`;\n}\n\n/**\n * Create a code text.\n *\n * Markdown: `code`\n *\n * @param text - The text to be marked as code.\n */\nexport function code(text: string): string {\n return `\\`${text}\\``;\n}\n\n/**\n * Create a link or autolink span.\n *\n * Markdown:\n * - `[text](url)` link when `text` is provided\n * - `<url>` autolink when `text` is not provided\n *\n * @param url - The URL to be linked.\n * @param text - The title for the link (optional).\n */\nexport function link(url: string, text?: string): string {\n return text ? `[${text}](${url})` : `<${url}>`;\n}\n\n/**\n * Create an image text.\n *\n * Markdown: ``\n *\n * @param url - The URL of the image.\n * @param text - The description for the image (optional).\n */\nexport function image(url: string, text?: string): string {\n return ``;\n}\n"],"mappings":"AAOA,OAAO,SAASA,MAAMA,CAACC,IAAY,EAAU;EAC3C,OAAO,IAAIA,IAAI,GAAG;AACpB;AASA,OAAO,SAASC,IAAIA,CAACD,IAAY,EAAU;EACzC,OAAO,KAAKA,IAAI,IAAI;AACtB;AASA,OAAO,SAASE,IAAIA,CAACF,IAAY,EAAU;EACzC,OAAO,KAAKA,IAAI,IAAI;AACtB;AAYA,OAAO,SAASG,IAAIA,CAACC,GAAW,EAAEJ,IAAa,EAAU;EACvD,OAAOA,IAAI,GAAG,IAAIA,IAAI,KAAKI,GAAG,GAAG,GAAG,IAAIA,GAAG,GAAG;AAChD;AAUA,OAAO,SAASC,KAAKA,CAACD,GAAW,EAAEJ,IAAa,EAAU;EACxD,OAAO,KAAKA,IAAI,IAAI,EAAE,KAAKI,GAAG,GAAG;AACnC","ignoreList":[]}
|
package/dist/esm/utils.mjs
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
export function joinBlocks(blocks) {
|
|
2
|
+
blocks = typeof blocks === 'string' ? [blocks] : blocks;
|
|
3
|
+
return blocks.map(trimBlock).filter(Boolean).join('\n\n');
|
|
4
|
+
}
|
|
5
|
+
function trimBlock(block) {
|
|
6
|
+
return block.replace(/^\n+|\n+$/g, '');
|
|
7
|
+
}
|
|
1
8
|
export function prefixLines(text, prefix) {
|
|
2
9
|
const lines = text.split('\n');
|
|
3
10
|
return lines.map(line => `${prefix}${line}`).join('\n');
|
package/dist/esm/utils.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.mjs","names":["prefixLines","text","prefix","lines","split","
|
|
1
|
+
{"version":3,"file":"utils.mjs","names":["joinBlocks","blocks","map","trimBlock","filter","Boolean","join","block","replace","prefixLines","text","prefix","lines","split","line"],"sources":["../../src/utils.ts"],"sourcesContent":["/**\n * Join blocks of text into a single markdown document (string).\n *\n * @param blocks - The blocks of text to join.\n * @returns Markdown document string.\n */\nexport function joinBlocks(blocks: string | readonly string[]): string {\n blocks = typeof blocks === 'string' ? [blocks] : blocks;\n\n return blocks.map(trimBlock).filter(Boolean).join('\\n\\n');\n}\n\nfunction trimBlock(block: string): string {\n return block.replace(/^\\n+|\\n+$/g, '');\n}\n\nexport function prefixLines(text: string, prefix: string): string {\n const lines = text.split('\\n');\n return lines.map((line) => `${prefix}${line}`).join('\\n');\n}\n"],"mappings":"AAMA,OAAO,SAASA,UAAUA,CAACC,MAAkC,EAAU;EACrEA,MAAM,GAAG,OAAOA,MAAM,KAAK,QAAQ,GAAG,CAACA,MAAM,CAAC,GAAGA,MAAM;EAEvD,OAAOA,MAAM,CAACC,GAAG,CAACC,SAAS,CAAC,CAACC,MAAM,CAACC,OAAO,CAAC,CAACC,IAAI,CAAC,MAAM,CAAC;AAC3D;AAEA,SAASH,SAASA,CAACI,KAAa,EAAU;EACxC,OAAOA,KAAK,CAACC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC;AACxC;AAEA,OAAO,SAASC,WAAWA,CAACC,IAAY,EAAEC,MAAc,EAAU;EAChE,MAAMC,KAAK,GAAGF,IAAI,CAACG,KAAK,CAAC,IAAI,CAAC;EAC9B,OAAOD,KAAK,CAACV,GAAG,CAAEY,IAAI,IAAK,GAAGH,MAAM,GAAGG,IAAI,EAAE,CAAC,CAACR,IAAI,CAAC,IAAI,CAAC;AAC3D","ignoreList":[]}
|
package/dist/types/block.d.ts
CHANGED
|
@@ -4,6 +4,9 @@
|
|
|
4
4
|
* Markdown: `---`
|
|
5
5
|
*/
|
|
6
6
|
export declare const horizontalRule = "---";
|
|
7
|
+
type HeadingOptions = {
|
|
8
|
+
level: number;
|
|
9
|
+
};
|
|
7
10
|
/**
|
|
8
11
|
* Create a heading block.
|
|
9
12
|
* Markdown: `# Heading`
|
|
@@ -11,7 +14,7 @@ export declare const horizontalRule = "---";
|
|
|
11
14
|
* @param text - The text of the heading.
|
|
12
15
|
* @param level - The level of the heading (defaults to 1).
|
|
13
16
|
*/
|
|
14
|
-
export declare function heading(text: string,
|
|
17
|
+
export declare function heading(text: string, options?: HeadingOptions): string;
|
|
15
18
|
/**
|
|
16
19
|
* Create a blockquote block.
|
|
17
20
|
*
|
|
@@ -23,7 +26,7 @@ export declare function heading(text: string, level?: number): string;
|
|
|
23
26
|
*
|
|
24
27
|
* @param text - The content of the blockquote.
|
|
25
28
|
*/
|
|
26
|
-
export declare function blockquote(content: string): string;
|
|
29
|
+
export declare function blockquote(content: string | readonly string[]): string;
|
|
27
30
|
/**
|
|
28
31
|
* Create a code block.
|
|
29
32
|
*
|
|
@@ -61,3 +64,4 @@ export declare function list(items: readonly string[]): string;
|
|
|
61
64
|
* @param items - The items of the list.
|
|
62
65
|
*/
|
|
63
66
|
export declare function orderedList(items: readonly string[]): string;
|
|
67
|
+
export {};
|
package/dist/types/html.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Create a line break.
|
|
3
3
|
*
|
|
4
|
-
* Markdown
|
|
4
|
+
* Markdown (as HTML): `<br/>`
|
|
5
5
|
*/
|
|
6
6
|
export declare const lineBreak = "<br/>";
|
|
7
7
|
/**
|
|
@@ -9,14 +9,14 @@ export declare const lineBreak = "<br/>";
|
|
|
9
9
|
*/
|
|
10
10
|
export type DisclosureOptions = {
|
|
11
11
|
/**
|
|
12
|
-
* Whether the disclosure block should be open by default.
|
|
12
|
+
* Whether the disclosure block should be open by default (defaults to false).
|
|
13
13
|
*/
|
|
14
14
|
open?: boolean;
|
|
15
15
|
};
|
|
16
16
|
/**
|
|
17
17
|
* Create a disclosure block.
|
|
18
18
|
*
|
|
19
|
-
* Markdown
|
|
19
|
+
* Markdown (as HTML):
|
|
20
20
|
* ```
|
|
21
21
|
* <details>
|
|
22
22
|
* <summary>Title</summary>
|
|
@@ -24,8 +24,8 @@ export type DisclosureOptions = {
|
|
|
24
24
|
* </details>
|
|
25
25
|
* ```
|
|
26
26
|
*
|
|
27
|
-
* @param title - The title of the disclosure.
|
|
28
|
-
* @param content - The content of the disclosure.
|
|
27
|
+
* @param title - The title of the disclosure (text only or markdown heading: `# heading`).
|
|
28
|
+
* @param content - The content of the disclosure (can include markdown).
|
|
29
29
|
* @param options - The options for the disclosure.
|
|
30
30
|
*/
|
|
31
31
|
export declare function disclosure(title: string, content: string, options?: DisclosureOptions): string;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { joinBlocks, joinLines } from './join';
|
|
2
1
|
export { horizontalRule, heading, blockquote, orderedList, list, codeBlock } from './block';
|
|
3
2
|
export { code, italic, bold, link, image } from './inline';
|
|
4
3
|
export { table } from './table';
|
|
5
4
|
export { lineBreak, disclosure } from './html';
|
|
5
|
+
export { joinBlocks } from './utils';
|
|
6
6
|
export type { TableOptions } from './table';
|
|
7
7
|
export type { DisclosureOptions } from './html';
|
package/dist/types/inline.d.ts
CHANGED
package/dist/types/utils.d.ts
CHANGED
|
@@ -1 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Join blocks of text into a single markdown document (string).
|
|
3
|
+
*
|
|
4
|
+
* @param blocks - The blocks of text to join.
|
|
5
|
+
* @returns Markdown document string.
|
|
6
|
+
*/
|
|
7
|
+
export declare function joinBlocks(blocks: string | readonly string[]): string;
|
|
1
8
|
export declare function prefixLines(text: string, prefix: string): string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts-markdown-builder",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Elegant markdown builder with minimal bundle size.",
|
|
5
5
|
"main": "dist/commonjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.mjs",
|
|
@@ -24,12 +24,12 @@
|
|
|
24
24
|
"typecheck": "tsc --noEmit",
|
|
25
25
|
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
26
26
|
"clean": "del-cli dist",
|
|
27
|
-
"
|
|
28
|
-
"release:beta": "release-it --preRelease=beta",
|
|
29
|
-
"build": "yarn clean && yarn build:commonjs && yarn build:esm && yarn build:typescript",
|
|
27
|
+
"build": "yarn clean && yarn build:commonjs && yarn build:esm && yarn build:types",
|
|
30
28
|
"build:commonjs": "BABEL_ENV=cjs babel src --out-dir \"dist/commonjs\" --extensions .js,.ts --out-file-extension .js --source-maps --no-comments",
|
|
31
29
|
"build:esm": "BABEL_ENV=esm babel src --out-dir \"dist/esm\" --extensions .js,.ts --out-file-extension .mjs --source-maps --no-comments",
|
|
32
|
-
"build:
|
|
30
|
+
"build:types": "tsc --project tsconfig.release.json --outDir \"dist/types\"",
|
|
31
|
+
"release": "release-it",
|
|
32
|
+
"release:beta": "release-it --preRelease=beta"
|
|
33
33
|
},
|
|
34
34
|
"keywords": [
|
|
35
35
|
"markdown",
|
|
@@ -53,11 +53,11 @@
|
|
|
53
53
|
"@babel/preset-env": "^7.25.4",
|
|
54
54
|
"@babel/preset-typescript": "^7.24.7",
|
|
55
55
|
"@callstack/eslint-config": "^15.0.0",
|
|
56
|
-
"@release-it/conventional-changelog": "^
|
|
57
|
-
"@size-limit/preset-small-lib": "^11.1.
|
|
56
|
+
"@release-it/conventional-changelog": "^9.0.0",
|
|
57
|
+
"@size-limit/preset-small-lib": "^11.1.6",
|
|
58
58
|
"@types/jest": "^29.5.12",
|
|
59
59
|
"babel-plugin-add-import-extension": "^1.6.0",
|
|
60
|
-
"del-cli": "^
|
|
60
|
+
"del-cli": "^6.0.0",
|
|
61
61
|
"eslint": "^8.57.0",
|
|
62
62
|
"eslint-config-prettier": "^8.10.0",
|
|
63
63
|
"eslint-plugin-flowtype": "^8.0.3",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"eslint-plugin-prettier": "^4.2.1",
|
|
66
66
|
"jest": "^29.7.0",
|
|
67
67
|
"prettier": "^2.8.8",
|
|
68
|
-
"release-it": "^17.
|
|
68
|
+
"release-it": "^17.10.0",
|
|
69
69
|
"typescript": "^5.5.4"
|
|
70
70
|
},
|
|
71
71
|
"packageManager": "yarn@4.4.1",
|
|
@@ -84,6 +84,15 @@
|
|
|
84
84
|
]
|
|
85
85
|
},
|
|
86
86
|
"release-it": {
|
|
87
|
+
"hooks": {
|
|
88
|
+
"before:init": [
|
|
89
|
+
"yarn typecheck",
|
|
90
|
+
"yarn test",
|
|
91
|
+
"yarn lint"
|
|
92
|
+
],
|
|
93
|
+
"after:bump": "yarn build",
|
|
94
|
+
"after:release": "echo Successfully released ${name} v${version} to ${repo.repository}."
|
|
95
|
+
},
|
|
87
96
|
"git": {
|
|
88
97
|
"commitMessage": "chore: release ${version}",
|
|
89
98
|
"tagName": "v${version}"
|
|
@@ -92,11 +101,36 @@
|
|
|
92
101
|
"publish": true
|
|
93
102
|
},
|
|
94
103
|
"github": {
|
|
95
|
-
"release": true
|
|
104
|
+
"release": true,
|
|
105
|
+
"releaseName": "v${version} (${date:yyyy-MM-dd})"
|
|
96
106
|
},
|
|
97
107
|
"plugins": {
|
|
98
108
|
"@release-it/conventional-changelog": {
|
|
99
|
-
"preset":
|
|
109
|
+
"preset": {
|
|
110
|
+
"name": "conventionalcommits",
|
|
111
|
+
"types": [
|
|
112
|
+
{
|
|
113
|
+
"type": "feat",
|
|
114
|
+
"section": "✨ Features"
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
"type": "perf",
|
|
118
|
+
"section": "💨 Performance Improvements"
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
"type": "fix",
|
|
122
|
+
"section": "🐛 Bug Fixes"
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
"type": "chore(deps)",
|
|
126
|
+
"section": "🛠️ Dependency Upgrades"
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
"type": "docs",
|
|
130
|
+
"section": "📚 Documentation"
|
|
131
|
+
}
|
|
132
|
+
]
|
|
133
|
+
}
|
|
100
134
|
}
|
|
101
135
|
}
|
|
102
136
|
},
|
package/dist/commonjs/join.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
exports.joinBlocks = joinBlocks;
|
|
4
|
-
exports.joinLines = joinLines;
|
|
5
|
-
var _html = require("./html.js");
|
|
6
|
-
function joinBlocks(blocks) {
|
|
7
|
-
return blocks.filter(Boolean).map(trimBlock).join('\n\n');
|
|
8
|
-
}
|
|
9
|
-
function joinLines(lines) {
|
|
10
|
-
return lines.filter(Boolean).join(_html.lineBreak);
|
|
11
|
-
}
|
|
12
|
-
function trimBlock(block) {
|
|
13
|
-
return block.replace(/^\n+|\n+$/g, '');
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=join.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"join.js","names":["joinBlocks","blocks","filter","Boolean","map","trimBlock","join","joinLines","lines","lineBreak","block","replace"],"sources":["../../src/join.ts"],"sourcesContent":["import { lineBreak } from './html';\n\n/**\n * Join blocks of text into a single markdown document (string).\n *\n * @param blocks - The blocks of text to join.\n * @returns Markdown document string.\n */\nexport function joinBlocks(blocks: readonly string[]): string {\n return blocks.filter(Boolean).map(trimBlock).join('\\n\\n');\n}\n\n/**\n * Join lines of text into a single paragraph string with line breaks.\n *\n * @param lines - The lines of text to join.\n * @returns Paragraph string.\n */\nexport function joinLines(lines: string[]) {\n return lines.filter(Boolean).join(lineBreak);\n}\n\nfunction trimBlock(block: string): string {\n return block.replace(/^\\n+|\\n+$/g, '');\n}\n"],"mappings":";;;;;AAQO,SAASA,UAAUA,CAACC,MAAyB,EAAU;EAC5D,OAAOA,MAAM,CAACC,MAAM,CAACC,OAAO,CAAC,CAACC,GAAG,CAACC,SAAS,CAAC,CAACC,IAAI,CAAC,MAAM,CAAC;AAC3D;AAQO,SAASC,SAASA,CAACC,KAAe,EAAE;EACzC,OAAOA,KAAK,CAACN,MAAM,CAACC,OAAO,CAAC,CAACG,IAAI,CAACG,eAAS,CAAC;AAC9C;AAEA,SAASJ,SAASA,CAACK,KAAa,EAAU;EACxC,OAAOA,KAAK,CAACC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC;AACxC","ignoreList":[]}
|
package/dist/esm/join.mjs
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { lineBreak } from "./html.mjs";
|
|
2
|
-
export function joinBlocks(blocks) {
|
|
3
|
-
return blocks.filter(Boolean).map(trimBlock).join('\n\n');
|
|
4
|
-
}
|
|
5
|
-
export function joinLines(lines) {
|
|
6
|
-
return lines.filter(Boolean).join(lineBreak);
|
|
7
|
-
}
|
|
8
|
-
function trimBlock(block) {
|
|
9
|
-
return block.replace(/^\n+|\n+$/g, '');
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=join.mjs.map
|
package/dist/esm/join.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"join.mjs","names":["lineBreak","joinBlocks","blocks","filter","Boolean","map","trimBlock","join","joinLines","lines","block","replace"],"sources":["../../src/join.ts"],"sourcesContent":["import { lineBreak } from './html';\n\n/**\n * Join blocks of text into a single markdown document (string).\n *\n * @param blocks - The blocks of text to join.\n * @returns Markdown document string.\n */\nexport function joinBlocks(blocks: readonly string[]): string {\n return blocks.filter(Boolean).map(trimBlock).join('\\n\\n');\n}\n\n/**\n * Join lines of text into a single paragraph string with line breaks.\n *\n * @param lines - The lines of text to join.\n * @returns Paragraph string.\n */\nexport function joinLines(lines: string[]) {\n return lines.filter(Boolean).join(lineBreak);\n}\n\nfunction trimBlock(block: string): string {\n return block.replace(/^\\n+|\\n+$/g, '');\n}\n"],"mappings":"SAASA,SAAS;AAQlB,OAAO,SAASC,UAAUA,CAACC,MAAyB,EAAU;EAC5D,OAAOA,MAAM,CAACC,MAAM,CAACC,OAAO,CAAC,CAACC,GAAG,CAACC,SAAS,CAAC,CAACC,IAAI,CAAC,MAAM,CAAC;AAC3D;AAQA,OAAO,SAASC,SAASA,CAACC,KAAe,EAAE;EACzC,OAAOA,KAAK,CAACN,MAAM,CAACC,OAAO,CAAC,CAACG,IAAI,CAACP,SAAS,CAAC;AAC9C;AAEA,SAASM,SAASA,CAACI,KAAa,EAAU;EACxC,OAAOA,KAAK,CAACC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC;AACxC","ignoreList":[]}
|
package/dist/types/join.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Join blocks of text into a single markdown document (string).
|
|
3
|
-
*
|
|
4
|
-
* @param blocks - The blocks of text to join.
|
|
5
|
-
* @returns Markdown document string.
|
|
6
|
-
*/
|
|
7
|
-
export declare function joinBlocks(blocks: readonly string[]): string;
|
|
8
|
-
/**
|
|
9
|
-
* Join lines of text into a single paragraph string with line breaks.
|
|
10
|
-
*
|
|
11
|
-
* @param lines - The lines of text to join.
|
|
12
|
-
* @returns Paragraph string.
|
|
13
|
-
*/
|
|
14
|
-
export declare function joinLines(lines: string[]): string;
|